#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <cstring>
using namespace std;


int main() {
  int i,j ,k;
  int N; cin >> N;
  int mat[111][111]; memset(mat, 0, sizeof(mat));
  int arr[111]; memset(arr, 0, sizeof(arr));
  for (i = 0; i < N; ++i)
    for (j = 0;j  < N; ++j) cin >> mat[i][j];
  for (i = 0; i < N; ++i) {
    for (j = 0; j < N; ++j) {
      if(i==j) continue;
      arr[i] |= mat[i][j];
    }
  }
  for (i = 0; i < N; ++i) {
    if (i) printf(" ");
    printf("%d", arr[i]);
  }printf("\n");
  return 0;
}
